﻿using Microsoft.Extensions.DependencyInjection;
using Rubyer;
using StockUI.ViewModels;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;


namespace StockUI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RubyerWindow
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = App.Current.Services.GetRequiredService<MainViewModel>();
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += Timer_Tick;
            timer.Start();
        }
        protected override void OnClosing(CancelEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var mainmodel = this.DataContext as MainViewModel;
        }

        private void TabControl_Selected(object sender, RoutedEventArgs e)
        {
            var mainmodel = this.DataContext as MainViewModel;
        }

        private void HamburgerMenu_HamburgerButtonClick(object sender, RoutedEventArgs e)
        {
            //Debug.WriteLine($"Current HamburgerMenu IsExpanded:{(sender as HamburgerMenu).IsExpanded}");

             e.Handled = true; // 取消切换
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            datetime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
    }
}